import { reactive } from '@vue/reactivity';
import {  getUserInfo } from '@/api/content.js'

const state = reactive({
  price: 0,
});

const mutations = {
  setPrice(price) {
    state.price = price;
  }
};

const actions = {
  fetchData() {
    // 调用接口获取数据
    // 然后调用 mutation 来更新状态
    // 示例代码：
    // api.fetchData().then(response => {
    //   mutations.setData(response.data);
    // });
    getUserInfo({
        id: sessionStorage.getItem('userId')
      }).then(res => {
        if (res.success) {
            mutations.setPrice(res.data[0].price);
            console.log(res.data[0].price);
        }
      })
  }
};

export default {
  state,
  mutations,
  actions
};